<?php
class Default_Form_User extends Zend_Form
{
    public function __construct()
    {
        parent::__construct($options);
        $this->setName('User');

        $this->addElement('hidden', 'id_user');


        $this->addElement('text', 'email', array(
            'label'      => 'Epasts: ',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                'NotEmpty',
                'EmailAddress'
            )
        ));

        $this->addElement('text', 'name', array(
            'label'      => 'Vārds: ',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                'NotEmpty',
            )
        ));

        $this->addElement('text', 'surname', array(
            'label'      => 'Uzvārds: ',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                'NotEmpty',
            )
        ));

        $this->addElement('text', 'password', array(
            'label'      => 'Parole:',
            'required'   => true,
            'filters'    => array(
                'StripTags',
                'StringTrim'
            ),
            'validators' => array(
                'NotEmpty',
                )
            )
        );



        $this->addElement('text', 'code', array(
            'label'      => 'Apliecības numurs:',
            'required'   => true,
            'filters'    => array(
                'StripTags',
                'StringTrim'
            ),
            'validators' => array(
                'NotEmpty',
                )
            )
        );



        $select = array(
            'guest' => 'ciemiņš',
            'student' => 'students',
            'teacher' => 'skolotājs'
        );

        $this->addElement('select', 'type',
            array(
                'label'     => 'Tips:',
                'filters'   => array('StringTrim', 'StripTags', 'StringToLower'),
                'required'  => true,
                'multiOptions' => $select,
            )
        );


        $select = array('0' => 'nav');
        $group = new Default_Model_DbTable_Groups();
        $groups = $group->fetchAll()->toArray();
        foreach($groups AS $data){
            $select[$data['id']] = $data['name'];
        }
        

        $this->addElement('select', 'group_id',
            array(
                'label'     => 'Grupa:',
                'filters'   => array('StringTrim', 'StripTags', 'StringToLower'),
                'required'  => true,
                'multiOptions' => $select,
            )
        );


        $this->addElement('submit', 'submit', array(
            'ignore'   => true,
            'label'    => 'Saglabāt',
        ));

    }
}